package common

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/common"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// CancelService 撤销服务
type CancelService struct {
	*services.BaseService
}

// NewCancelService 创建撤销服务
func NewCancelService(config *core.Config) *CancelService {
	return &CancelService{
		BaseService: services.NewBaseService(config),
	}
}

// Cancel 撤销
func (s *CancelService) Cancel(request *common.CancelRequest) (*common.CancelResponse, error) {
	response := common.NewCancelResponse()
	err := s.Post(request, response, "/open/trans/cancel")
	if err != nil {
		return nil, err
	}
	return response, nil
}
